package com.three.productList.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.three.core.entity.Product;
import com.three.core.entity.ProductType;
import com.three.productList.service.ProductTypeService;
import com.three.core.vo.R;
import com.three.productList.vo.SearchForm;
import com.three.productList.vo.SearchForm2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：li
 * @date ：Created in 2025/3/11 011 16:41
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/product/type")
public class ProductTypeController {
    @Autowired
    private ProductTypeService productTypeservice;
    //查询所有数据,无条件
    @GetMapping("/selectAllProductType")
    public R<List<ProductType>> selectAllProductType() {
        return productTypeservice.selectAllProductType();
    }
    //查询数据，展示表单数据
    @PostMapping("/select")
    public R<Page<ProductType>> selectProductType(@RequestBody SearchForm2 searchForm) {
        return productTypeservice.selectProductTypes(searchForm);
    }
    //根据id删除数据
    @GetMapping("/deleteProductTypeById")
    public R<ProductType> deleteProductTypeById(Integer commentId) {
        return productTypeservice.deleteProductTypeById(commentId);
    }
    //是否允许被修改
    @PostMapping("/change")
    public R<ProductType> change(@RequestParam Integer commentId,@RequestParam Long isedit) {
        return productTypeservice.updateIseditByChangeId(commentId,isedit);
    }
    //添加数据
    @PostMapping("/insertProductType")
    public R<ProductType> insertProductType(@RequestBody ProductType productType) {
        return productTypeservice.addProductType(productType);
    }
    //确认编辑
    @PostMapping("/updateProductType")
    public R<ProductType> updateProductType(@RequestBody ProductType productType) {
        return productTypeservice.updateProductType(productType);
    }

}
